/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBLayer;
import ModelLayer.SalesLine;
import Prototypes.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Moulde
 */
public class DBSalesLineContainer extends DataLayer
{
    private static DBSalesLineContainer instance;

    public DBSalesLineContainer()
    {
        super();
    }

    public 

    public boolean addSalesLine(SalesLine salesLine)
    {
        try
        {
            String sql = "INSERT INTO WSSalesLine VALUES(" + salesLine.getProduct().getProductID() + ", " + salesLine.getSalesOrder().getSalesOrderID() + ", " + salesLine.getAmount() + ")";
            Statement statement = dbConnection.createStatement();
            int updatedRowCount = statement.executeUpdate(sql);

            return updatedRowCount > 0;
        }
        catch (SQLException ex)
        {
            Logger.getLogger(DBSalesLineContainer.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }

    public static DBSalesLineContainer getInstance()
    {
        if (instance == null)
        {
            instance = new DBSalesLineContainer();
        }
        return instance;
    }
}
